package cn.ibdsr.human.util;

import cn.ibdsr.human.constant.GunsExceptionEnum;
import cn.ibdsr.human.exception.GunsException;
import com.alibaba.fastjson.JSON;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @description:
 * @author: cdl
 * @email: iamcimon@qq.com
 * @date: 2021/8/2 13:20
 */
public class RenderUtil {
    public RenderUtil() {
    }

    public static void renderJson(HttpServletResponse response, Object jsonObject) {
        try {
            response.setContentType("application/json");
            response.setCharacterEncoding("UTF-8");
            PrintWriter writer = response.getWriter();
            writer.write(JSON.toJSONString(jsonObject));
        } catch (IOException var3) {
            throw new GunsException(GunsExceptionEnum.WRITE_ERROR);
        }
    }
}
